/**
 * Heterotopia - an up-to-date Java-based MUD system
 * Copyright (C) 2011 Bill Garrett <memesis@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package heterotopia;

import heterotopia.oa.ObjectRegistry;

import org.apache.camel.impl.CompositeRegistry;
import org.apache.camel.spring.spi.ApplicationContextRegistry;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * A Camel CompositeRegistry which bootstraps itself from the existing Spring application framework.
 * 
 * @author garrett
 */
public class HeterotopiaRegistry extends CompositeRegistry implements ApplicationContextAware {
	/**
	 * Constructs a new composite registry.
	 */
	public HeterotopiaRegistry() {
		super();
		// TODO: add additional registries here, like the object activator and network-aware federation stuff.
	}

	/**
	 * When called by Spring, updates the list of registries to include the Spring context itself,
	 * along with ObjectRegistry.
	 * 
	 * @see heterotopia.oa.ObjectRegistry
	 */
	public void setApplicationContext(ApplicationContext arg0)
			throws BeansException {
		addRegistry(new ApplicationContextRegistry(arg0));
		addRegistry(new ObjectRegistry());
	}
}